package com.day2sockettest;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

/**
 * 接收客户端数据
 */

public class ServerThread extends Thread {
    private Socket socket;

  public ServerThread(Socket socket) {
        this.socket = socket;
    }
    BufferedReader br = null;

    @Override
    public void run() {
        String str = null;
        try {
            br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            while (!(str = br.readLine()).equals("exit")) {
                    System.out.println("客户端说" + str);
                }
            br.close();
            } catch(IOException e){
                e.printStackTrace();
            }
        }
    }
